import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class util {
    public static String mileage_notnull(String S){
        String result = "0";
        if (S!=null) {
            S = S.replaceAll(" \\s*", "");
        }
        if ("".equals(S) || S == null) {
            result = "0";
        }
        else {

            Pattern pattern = Pattern.compile("([0-9]+)");
            Matcher matcher = pattern.matcher(S);
            if (matcher.find()) {
                result = matcher.group(1);

            }else{
                result = "0";
            }









        }
        return result;

    }



    public static Date date_notnull(Date date) throws ParseException {

        DateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        Date result = df.parse("1970-01-01 00:00:00");
        if(date !=null){
            result = date;
        }
        return result;
    }
    public static String  LAT_notnull(String S)  {
        String result = "0";


        if(S!=null){
            result = S;
        }
        return result;
    }
    public static Long  num_notnull(Long L)  {
        Long result = 0L;


        if(L!=null){
            result = L;
        }
        return result;
    }
    public static String  province_notnull(String S)  {
        String result = "空";


        if(S!=null){
            result = S;
        }
        return result;
    }
    public static String  Date_year(Date date) throws ParseException {
        String result = "空";


        DateFormat df = new SimpleDateFormat("yyyy");

        if(date !=null){
            result = df.format(date);
        }
        return result;
    }

}
